/* eslint-disable no-param-reassign */
/* eslint-disable react/jsx-key */
import React, { useState, useRef } from 'react';
import ReactDOM from 'react-dom';
import { Image, Popconfirm, Tooltip, Modal, Button, Alert, message } from 'antd';
import AutoTable from '@/components/AutoTable';
import InitForm from '@/components/InitForm';
import { area, classify, user, basic_info } from '@/services/basic';
import { connect, useRequest } from 'umi';
import ProDescriptions from '@ant-design/pro-descriptions';
import { DownloadOutlined } from '@ant-design/icons';
import { postFetch, getFetch, doFetch } from '@/utils/doFetch';
import moment from 'moment';
import CompanyName from '@/components/CompanyName';


let options = [
    {
      id: 'cache',
      name: '暂存',
    },
    {
      id: 'dispatch_refuse',
      name: '被拒绝',
    },
  ],
  valueEnum = {
    cache: {
      text: '暂存',
    },
    stalled: {
      text: '未开始',
    },
    dispatching: {
      text: '会计调度中',
    },
    dispatch_refuse: {
      text: '会计调度拒绝',
    },
    accounting: {
      text: '记账会计审核中',
    },
    account_refuse: {
      text: '记账会计拒绝',
    },
    account_cache: {
      text: '记账会计暂存',
    },
    completed: {
      text: '已完成',
    },
  };

let defaultFields = {
  title: {
    value: null,
    type: 'render',
    title: '客户基础信息变更',
    name: ['title'],
    render: () => {
      return <Alert message="客户基础信息变更" style={{ marginBottom: 20 }} showIcon type="info" />;
    },
    col: {
      span: 24,
    },
  },
  snapshot: {
    value: null,
    type: 'recognition',
    title: '营业执照',
    name: ['snapshot'],
    required: false,
  },
  contracts: {
    value: null,
    type: 'upload',
    title: '合同协议',
    name: ['contracts'],
    required: true,
    listType: 'img',
    multiple: true,
    limit: 20,
  },
  name: {
    value: null,
    type: 'input',
    title: '公司全称',
    name: ['name'],
    required: true,
  },
  address: {
    value: null,
    type: 'input',
    title: '公司地址',
    name: ['address'],
    required: false,
  },
  enterprise_credit_code: {
    value: null,
    type: 'input',
    title: '统一社会信用代码',
    name: ['enterprise_credit_code'],
    required: false,
  },

  legal_person: {
    value: null,
    type: 'input',
    title: '公司法人',
    name: ['legal_person'],
    required: false,
  },
  customer_name: {
    value: null,
    type: 'input',
    title: '联系人',
    name: ['customer_name'],
    required: true,
  },
  customer_phone: {
    value: null,
    type: 'input',
    title: '联系人手机号',
    width: 120,
    name: ['customer_phone'],
    required: true,
  },
  area_id: {
    value: null,
    type: 'select',
    title: '区域',
    name: ['area_id'],
    required: true,
    linked: true,
    options: {
      database: area,
      params: { is_all: 1 },
    },
  },
  classify_id: {
    value: null,
    type: 'select',
    title: '公司类型',
    name: ['classify_id'],
    required: true,
    options: {
      database: classify,
      params: { is_all: 1 },
    },
  },
  titles: {
    value: null,
    type: 'render',
    title: '客户申报信息变更',
    name: ['titles'],
    render: () => {
      return <Alert message="客户申报信息变更" style={{ marginBottom: 20 }} showIcon type="info" />;
    },
    col: {
      span: 24,
    },
  },
  state_tax_password: {
    value: null,
    type: 'input',
    title: '国税申报密码',
    name: ['state_tax_password'],
    required: true,
  },
  personal_tax_password: {
    value: null,
    type: 'input',
    title: '个税申报密码',
    name: ['personal_tax_password'],
    required: true,
  },
  drawer: {
    value: null,
    type: 'input',
    title: '税控盘开票人密码',
    name: ['drawer'],
    required: true,
  },
  certificate: {
    value: null,
    type: 'input',
    title: '税控盘证书密码',
    name: ['certificate'],
    required: true,
  },
  finance_mainer_type: {
    value: 'company',
    type: 'radio',
    title: '财务负责人类型',
    name: ['finance_mainer_type'],
    required: true,
    linked: true,
    options: [
      {
        value: 'company',
        label: '本公司',
      },
      {
        value: 'customer',
        label: '客户',
      },
    ],
  },
  finance_mainer_id: {
    value: null,
    type: 'select',
    title: '财务负责人',
    name: ['finance_mainer_id'],
    required: true,
    options: {
      database: user,
      params: { is_all: 1 },
    },
    belinked: {
      hides: [
        {
          name: 'finance_mainer_type',
          equalvalue: ['customer'],
          required: true,
        },
      ],
    },
  },
  finance_mainer_name: {
    value: null,
    type: 'input',
    title: '财务负责人',
    name: ['finance_mainer_name'],
    required: true,
    belinked: {
      hides: [
        {
          name: 'finance_mainer_type',
          equalvalue: ['company'],
          required: true,
        },
      ],
    },
  },
  taxer_type: {
    value: 'company',
    type: 'radio',
    title: '办税人类型',
    name: ['taxer_type'],
    required: true,
    linked: true,
    options: [
      {
        value: 'company',
        label: '本公司',
      },
      {
        value: 'customer',
        label: '客户',
      },
    ],
  },
  taxer_id: {
    value: null,
    type: 'select',
    title: '办税人',
    name: ['taxer_id'],
    required: true,
    options: {
      database: user,
      params: { is_all: 1 },
    },
    belinked: {
      hides: [
        {
          name: 'taxer_type',
          equalvalue: ['customer'],
          required: true,
        },
      ],
    },
  },
  taxer_name: {
    value: null,
    type: 'input',
    title: '办税人',
    name: ['taxer_name'],
    required: true,
    belinked: {
      hides: [
        {
          name: 'taxer_type',
          equalvalue: ['company'],
          required: true,
        },
      ],
    },
  },
  tax_phone_type: {
    value: 'company',
    type: 'radio',
    title: '税务申报手机号类型',
    name: ['tax_phone_type'],
    required: true,
    options: [
      {
        value: 'company',
        label: '本公司',
      },
      {
        value: 'customer',
        label: '客户',
      },
    ],
  },
  tax_phone: {
    value: '',
    type: 'input',
    title: '税务申报手机号',
    name: ['tax_phone'],
    required: true,
  },
  liaisoner_type: {
    value: 'company',
    type: 'radio',
    title: '工商联络员类型',
    name: ['liaisoner_type'],
    required: true,
    options: [
      {
        value: 'company',
        label: '本公司',
      },
      {
        value: 'customer',
        label: '客户',
      },
    ],
  },
  liaisoner_phone: {
    value: '',
    type: 'input',
    title: '工商联络员手机号',
    name: ['liaisoner_phone'],
    required: true,
  },
  id_card: {
    value: null,
    type: 'input',
    title: '工商联络员身份证号',
    name: ['id_card'],
    required: true,
  },
  bank: {
    value: null,
    type: 'input',
    title: '客户开户行',
    name: ['bank'],
    required: true,
  },
  bank_number: {
    value: null,
    type: 'input',
    title: '客户开户账号',
    name: ['bank_number'],
    required: true,
  },
};

const tabList = [
  {
    key: '1',
    tab: '正常',
  },
  {
    key: '2',
    tab: '解约',
  },
];

function Company(props) {
  const [vs, cvs] = useState(false), //表单显/隐
    [iftype, ciftype] = useState({}),
    [fields, cf] = useState(defaultFields),
    [sd, csd] = useState(false);

  let actionRef = useRef(),
    ChildRef = null,
    formRef = useRef();
  function reload() {
    actionRef?.current?.reload();
    ChildRef?.onRefresh();
  }

  const { data } = useRequest(() => {
    return basic_info({ id: 4 });
  });

  const columns = [
      {
        title: '业务编号',
        dataIndex: 'code',
        key: 'code',
        search: false,
      },
      {
        title: '公司名称',
        width: 260,
        dataIndex: 'name',
        key: 'name',
        copyable: true,
        render: (_, row) => (
          <CompanyName
            row={{ ...row, name: row?.company_name??row.name, id: row?.company_id??row.id }}
            reload={reload}
          />
        ),
      },
      {
        title: '月收费',
        dataIndex: 'unit_price',
        key: 'unit_price',
        search: false,
      },
      {
        title: '公司法人',
        dataIndex: 'legal_person',
        key: 'legal_person',
        search: false,
        hideInTable: true,
      },
      {
        title: '公司地址',
        dataIndex: 'address',
        key: 'address',
        search: false,
        hideInTable: true,
      },
      {
        title: '统一社会信用代码',
        dataIndex: 'enterprise_credit_code',
        key: 'enterprise_credit_code',
        search: false,
        hideInTable: true,
      },
      {
        title: '公司营业执照',
        dataIndex: 'origin_url',
        key: 'origin_url',
        render: (_, row) => {
          return <Image width={32} height={32} style={{ padding: 2 }} src={row.origin_url} />;
        },
        hideInTable: true,
        search: false,
      },
      {
        title: '联系人',
        dataIndex: 'customer_name',
        key: 'customer_name',
        ellipsis: true,
      },
      {
        title: '联系人手机号',
        width: 120,
        dataIndex: 'customer_phone',
        key: 'customer_phone',
        render: (_, row) => (
          <Tooltip title={row.customer_phone}>
            <a href={`tel:${row.customer_phone}`} className="oneline">
              {row.customer_phone}
            </a>
          </Tooltip>
        ),
      },
      {
        title: '区域名称',
        dataIndex: 'area_name',
        key: 'area_id',
        valueType: 'select',
        options: {
          database: area,
          params: {
            is_all: 1,
          },
        },
      },
      {
        title: '区域编码',
        dataIndex: 'area_code',
        key: 'area_code',
        search: false,
        hideInTable: true,
      },
      {
        title: '接单人',
        dataIndex: 'user_name',
        key: 'user_id',
        valueType: 'select',
        options: {
          database: user,
          params: { is_all: 1 },
        },
      },
      {
        title: '促单人',
        dataIndex: 'promoter_user_name',
        key: 'promoter_user_name',
        search: false,
        hideInTable: true,
      },
      {
        title: '公司类型',
        dataIndex: 'classify_name',
        key: 'classify_id',
        valueType: 'select',
        options: {
          database: classify,
          params: { is_all: 1 },
        },
      },
      {
        title: '活动',
        dataIndex: 'activity_content',
        key: 'activity_content',
        search: false,
        hideInTable: true,
      },
      {
        title: '成立日期',
        dataIndex: 'establish_date',
        key: 'establish_date',
        search: false,
        render: (text, row) => {
          return row?.establish_date ? moment(row.establish_date).format('YYYY-MM-DD') : '-';
        },
      },
      {
        title: '签约日期',
        dataIndex: 'sign_date',
        key: 'sign_date',
        search: false,
        render: (text, row) => {
          return row?.sign_date ? moment(row.sign_date).format('YYYY-MM-DD') : '-';
        },
      },
      {
        title: '签约日期-开始',
        dataIndex: 'sign_date_start',
        key: 'sign_date_start',
        valueType: 'date',
        hideInTable: true,
        hideInDescription: true,
      },
      {
        title: '签约日期-结束',
        dataIndex: 'sign_date_end',
        key: 'sign_date_end',
        valueType: 'date',
        hideInTable: true,
        hideInDescription: true,
      },
      {
        title: '关注公众号',
        dataIndex: 'is_attention',
        key: 'is_attention',
        valueType: 'select',
        options: [
          {
            label: '已关注',
            value: true,
          },
          {
            label: '未关注',
            value: false,
          },
        ],
        render: (text, row) => {
          return row.is_attention ? (
            <span style={{ color: 'green' }}>已关注</span>
          ) : (
            <span style={{ color: '#ff4800' }}>未关注</span>
          );
        },
      },

      {
        title: '状态',
        dataIndex: 'status',
        key: 'status',
        valueType: 'select',
        options: options,
        valueEnum: valueEnum,
        search: false,
        render: (_, row) => <div className="oneline">合作中</div>,
      },
      {
        title: '合同协议',
        dataIndex: 'contracts',
        key: 'contracts',
        search: false,
        render: (_, row) => {
          if (!row.contracts) {
            return (
              <Image
                width={32}
                height={32}
                style={{ padding: 2 }}
                src={require('@/assets/default.png')}
              />
            );
          } else {
            return row.contracts.map((it) => {
              return <Image width={32} height={32} src={it.origin_url} style={{ padding: 2 }} />;
            });
          }
        },
        hideInTable: true,
      },
      {
        title: '记账会计',
        dataIndex: 'account_user_name',
        key: 'account_user_name',
      },
      {
        title: '记账方式',
        dataIndex: 'account_type',
        key: 'account_type',
        search: false,
        hideInTable: true,
        render: (_, row) => {
          return (
            <span>
              {row.account_type == 'k3'
                ? '金蝶k3'
                : row.account_type == 'simple'
                ? '简易记账'
                : '不记账'}
            </span>
          );
        },
      },
      {
        title: '会计主管',
        dataIndex: 'zhuguan',
        key: 'zhuguan',
        search: false,
        render: (_, row) => {
          return (
            <span>
              {data.map((it) => {
                let name = '';
                if (it.areas.indexOf(row.area_id) != -1) {
                  name = it.user.name;
                }
                return name ? name + '  ' : '';
              })}
            </span>
          );
        },
      },
      {
        title: '税务工商申报',
        dataIndex: 'info',
        key: 'info',
        search: false,
        render: (_, row) => (
          <a
            style={{ color: '#f50' }}
            onClick={() => {
              ciftype({
                ...iftype,
                val: 'seeshenbao',
                title: '查看详情',
                curitem: row,
              });
              cvs(true);
            }}
          >
            查看
          </a>
        ),
      },
      {
        title: '收款单',
        dataIndex: 'id',
        key: 'id',
        search: false,
        render: (_, row) => (
          <a
            style={{ color: '#f50' }}
            onClick={() => {
              ciftype({
                ...iftype,
                val: 'skd',
                title: '收款单',
                curitem: row,
              });
              cvs(true);
            }}
          >
            查看
          </a>
        ),
      },
      // {
      //   title: '变更客户信息',
      //   valueType: 'options',
      //   search: false,
      //   render: (_, record) => (
      //     <a
      //       onClick={() => {
      //         cvs(true);
      //         cf((fields) => {
      //           for (let i in defaultFields) {
      //             defaultFields[i].value = record[i];
      //             if (i == 'snapshot') {
      //               defaultFields[i].value = {
      //                 origin_url: record.origin_url,
      //                 preview_url: record.preview_url,
      //               };
      //             }
      //             if (i == 'user_id') {
      //               defaultFields[i].value = record.promoter_user_id;
      //             }
      //           }
      //           return { ...defaultFields };
      //         });
      //         ciftype({
      //           val: 'edit',
      //           title: '编辑业务',
      //           id: record.id,
      //           type: record.status,
      //         });
      //       }}
      //     >
      //       编辑
      //     </a>
      //   ),
      // },
    ],
    columnes = [
      {
        title: '国税申报密码',
        dataIndex: 'state_tax_password',
        key: 'state_tax_password',
        search: false,
      },
      {
        title: '个税申报密码',
        dataIndex: 'personal_tax_password',
        key: 'personal_tax_password',
        search: false,
      },
      {
        title: '税控盘开票人密码',
        dataIndex: 'drawer',
        key: 'drawer',
        search: false,
      },
      {
        title: '税控盘证书密码',
        dataIndex: 'certificate',
        key: 'certificate',
        search: false,
      },
      {
        title: '财务负责人',
        dataIndex: 'finance_mainer_type',
        key: 'finance_mainer_type',
        search: false,
        render: (_, row) => {
          return (
            <span>
              [{row.finance_mainer_type == 'customer  ' ? '客户' : '本司'}]{' '}
              {row.finance_mainer_name || '无'}
            </span>
          );
        },
      },
      {
        title: '办税人',
        dataIndex: 'taxer_type',
        key: 'taxer_type',
        search: false,
        render: (_, row) => {
          return (
            <span>
              [{row.taxer_type == 'customer  ' ? '客户' : '本司'}] {row.taxer_name || '无'}
            </span>
          );
        },
      },
      {
        title: '税务申报手机',
        dataIndex: 'tax_phone_type',
        key: 'tax_phone_type',
        search: false,
        render: (_, row) => {
          return (
            <span>
              [{row.tax_phone_type == 'customer  ' ? '客户' : '本司'}] {row.tax_phone}
            </span>
          );
        },
      },
      {
        title: '联络员手机号',
        dataIndex: 'liaisoner_type',
        key: 'liaisoner_type',
        search: false,
        render: (_, row) => {
          return (
            <span>
              [{row.liaisoner_type == 'customer  ' ? '客户' : '本司'}] {row.liaisoner_phone}
            </span>
          );
        },
      },
      {
        title: '工商联络员身份证号',
        dataIndex: 'id_card',
        key: 'id_card',
        search: false,
      },
      {
        title: '客户开户行',
        dataIndex: 'bank',
        key: 'bank',
        search: false,
      },
      {
        title: '客户开户行号码',
        dataIndex: 'bank_number',
        key: 'bank_number',
        search: false,
      },
    ];

  let saveData = (values) => {
    let { dispatch } = props;
    values = {
      ...values,
      ...values.snapshot,
    };
    if (iftype.val == 'exchange') {
      dispatch({
        type: 'business/batch_change_account',
        payload: values,
      }).then((res) => {
        if (res.code == 0) {
          reload();
          cvs(false);
        }
      });
    } else if (iftype.val == 'edit') {
      //{ ...values, id: iftype.id }
      let newvalue = {
        ...values,
        ...values.snapshot,
        id: iftype.id,
      };

      postFetch({
        url: '/wbn-api/company/change_company_info',
        params: { ...newvalue },
        method: 'PUT',
      }).then((res) => {
        if (res.code == 0) {
          message.success('客户信息更新成功！');
          reload();
          cvs(false);
        }
      });
    }
  };
  const [tabkey, setTabkey] = useState('1');

  return (
    <div className="pgcontainer">
      {data && (
        <AutoTable
          tabList={tabList}
          bordered={false}
          pagetitle={props.route.name} //页面标题
          pageextra={[
            // <a
            //   onClick={() => {
            //     cvs(true);
            //     let sfields = {
            //       company_ids: {
            //         value: null,
            //         type: 'checktable',
            //         title: '代账公司',
            //         name: ['company_ids'],
            //         columns: [
            //           {
            //             title: '业务编号',
            //             dataIndex: 'code',
            //             key: 'code',
            //           },
            //           {
            //             title: '公司名称',
            //             width: 260,
            //             dataIndex: 'name',
            //             key: 'name',
            //             copyable: true,
            //           },
            //           {
            //             title: '月收费',
            //             dataIndex: 'unit_price',
            //             key: 'unit_price',
            //             search: false,
            //           },
            //           {
            //             title: '公司法人',
            //             dataIndex: 'legal_person',
            //             key: 'legal_person',
            //             search: false,
            //           },
            //           {
            //             title: '联系人',
            //             dataIndex: 'customer_name',
            //             key: 'customer_name',
            //             ellipsis: true,
            //             search: false,
            //           },
            //           {
            //             title: '联系人手机号',
            //             width: 120,
            //             dataIndex: 'customer_phone',
            //             key: 'customer_phone',
            //             search: false,
            //             render: (_, row) => (
            //               <Tooltip title={row.customer_phone}>
            //                 <a href={`tel:${row.customer_phone}`} className="oneline">
            //                   {row.customer_phone}
            //                 </a>
            //               </Tooltip>
            //             ),
            //           },
            //           {
            //             title: '区域名称',
            //             dataIndex: 'area_name',
            //             key: 'area_name',
            //             search: false,
            //           },
            //           {
            //             title: '记账会计',
            //             dataIndex: 'account_user_name',
            //             key: 'account_user_id',
            //             valueType: 'select',
            //             options: {
            //               database: user,
            //               params: {
            //                 is_all: 1,
            //               },
            //             },
            //           },
            //           {
            //             title: '公司类型',
            //             dataIndex: 'classify_name',
            //             key: 'classify_name',
            //             search: false,
            //           },
            //         ],
            //         rowKey: 'id',
            //         rowName: 'name',
            //         required: true,
            //         path: '/wbn-api/company',
            //         extraparams: {
            //           type: -1,
            //           account_user_id: props.user.currentUser.id,
            //           status: 'completed',
            //           service_type: 'account',
            //         },
            //         col: { span: 24 },
            //       },
            //       account_user_id: {
            //         value: null,
            //         type: 'select',
            //         title: '转至会计',
            //         name: ['account_user_id'],
            //         required: true,
            //         options: {
            //           database: user,
            //           params: { is_all: 1 },
            //         },
            //         col: { span: 24 },
            //       },
            //     };
            //     cf(sfields);
            //     ciftype({
            //       val: 'exchange',
            //       title: '批量会计变更',
            //     });
            //   }}
            //   style={{
            //     lineHeight: '36px',
            //     marginRight: 12,
            //   }}
            // >
            //   批量会计变更
            // </a>,
            <div
              className="action"
              title="导出"
              style={{ background: '#ff4800', width: 'auto' }}
              onClick={() => {
                const hide = message.loading('正在导出..', 0);
                let julu = formRef?.current?.getFieldValue() ?? {};
                let extra = {
                  type: -1,
                  status: 'completed',
                  account_user_id: props.user.currentUser.id,
                };
                getFetch({
                  url: '/wbn-api/company/batch_import',
                  params: { ...julu, ...extra },
                }).then((res) => {
                  if (res?.data) {
                    window.open(res?.data);
                    hide();
                  }
                });
              }}
            >
              <DownloadOutlined />
            </div>,
          ]}
          columns={
            tabkey === '1'
              ? columns
              : [
                  ...columns,
                  {
                    title: '操作',
                    valueType: 'option',
                    width: 100,
                    render: (text, record, _, action) => (
                      <Popconfirm
                        placement="bottom"
                        title={'确认恢复正常？'}
                        onConfirm={() => {
                          doFetch({
                            url: '/wbn-api/company/change_rescind_company',
                            params: { id: record.id },
                            method: 'PUT',
                          }).then((res) => {
                            if (res.code === 0) {
                              message.success('操作成功');
                              reload();
                            }
                          });
                        }}
                        okText="恢复正常"
                        cancelText="取消"
                      >
                        <a style={{ color: '#1890ff' }}>恢复正常</a>
                      </Popconfirm>
                    ),
                  },
                ]
          }
          actionRef={actionRef}
          formRef={formRef}
          onRef={(node) => (ChildRef = node)}
          path={tabkey === '1' ? '/wbn-api/company' : '/wbn-api/company/rescind_company_list'}
          extraparams={
            tabkey === '1'
              ? {
                  type: -1,
                  status: 'completed',
                  account_user_id: props.user.currentUser.id,
                }
              : {}
          }
          onTabChange={(key) => {
            setTabkey(key);
          }}
          //withCard={false}
          //cardtitle = "name" //卡片标题
          //cardavatar = "img_url" //卡片头像
        />
      )}

      <Modal
        maskClosable={false}
        title={iftype.title}
        open={vs}
        onCancel={() => cvs(false)}
        footer={false}
        width={1400}
        destroyOnClose={true}
        style={{ top: 20 }}
      >
        {iftype.val == 'skd' ? (
          <div>
            <Alert
              message="显示/隐藏代账公司详情"
              style={{ marginBottom: 20 }}
              showIcon
              type="info"
              action={
                <Button
                  size="small"
                  type="primary"
                  onClick={() => {
                    csd(!sd);
                  }}
                >
                  {!sd ? '显示' : '隐藏'}
                </Button>
              }
            />
            <div
              style={{
                backgroundColor: '#f9f9f9',
                padding: sd ? 12 : 0,
                paddingBottom: 0,
                borderRadius: 8,
                height: sd ? 'auto' : 0,
                transition: 'all 0.4s',
                overflow: 'hidden',
              }}
            >
              <ProDescriptions
                title={`${iftype.curitem.name}的详细信息`}
                columns={[
                  ...columns.filter((it) => it.key != 'user_name' || it.hideInDescription === true),
                ]}
                column={{ xs: 1, sm: 1, md: 2, lg: 3, xl: 4, xxl: 5 }}
                dataSource={iftype.curitem}
              />
            </div>
            <AutoTable
              columns={[
                {
                  title: '本期收费单号',
                  dataIndex: 'settle_id',
                  key: 'settle_id',
                  width: 100,
                  copyable: true,
                  search: false,
                  render: (_, row) => (
                    <span>
                      {row.settle_id ? (Array(5).join(0) + row.settle_id).slice(-5) : '-'}
                    </span>
                  ),
                },
                {
                  title: '公司名称',
                  width: 260,
                  dataIndex: 'company_name',
                  key: 'company_name',
                  render: (_, row) => (
                    <CompanyName
                      row={{ ...row, name: row?.company_name ?? row?.name, id: row?.company_id ?? row?.id }}
                      reload={reload}
                    />
                  ),
                  search: false,
                },
                {
                  title: '应收款',
                  dataIndex: 'receivable',
                  key: 'receivable',
                  search: false,
                },
                {
                  title: '月收费',
                  dataIndex: 'unit_price',
                  key: 'unit_price',
                  search: false,
                },
                {
                  title: '服务开始时间',
                  dataIndex: 'service_start_time',
                  key: 'service_start_time',
                  width: 100,
                  search: false,
                },
                {
                  title: '服务结束时间',
                  dataIndex: 'service_end_time',
                  key: 'service_end_time',
                  width: 100,
                  search: false,
                },
                {
                  title: '接单人',
                  dataIndex: 'user_name',
                  key: 'user_name',
                  search: false,
                },
                {
                  title: '支付周期',
                  dataIndex: 'payment_cycle_name',
                  key: 'payment_cycle_name',
                  search: false,
                },
                {
                  title: '周期月数',
                  dataIndex: 'cycle_num',
                  key: 'cycle_num',
                  search: false,
                },
                {
                  title: '支付类型',
                  dataIndex: 'payment_type',
                  key: 'payment_type',
                  search: false,
                },
                {
                  title: '收款日期',
                  dataIndex: 'payment_time',
                  key: 'payment_time',
                  search: false,
                },
                {
                  title: '实际收款',
                  dataIndex: 'actual_receive',
                  key: 'actual_receive',
                  search: false,
                },
                {
                  title: '收款方式',
                  dataIndex: 'payment_name',
                  key: 'payment_name',
                  search: false,
                },
                {
                  title: '备注',
                  dataIndex: 'remark',
                  key: 'remark',
                  search: false,
                },
                {
                  title: '状态',
                  dataIndex: 'status',
                  key: 'status',
                  valueType: 'select',
                  options: [
                    {
                      id: 'cashiering',
                      name: '出纳审核中',
                    },
                    {
                      id: 'cashier_refuse',
                      name: '出纳拒绝',
                    },
                    {
                      id: 'cache',
                      name: '待激活',
                    },
                  ],
                  valueEnum: {
                    cache: {
                      text: '待激活',
                      status: 'error',
                    },
                    cashiering: {
                      text: '出纳审核中',
                    },
                    cashier_refuse: {
                      text: '出纳拒绝',
                    },
                    accounting: {
                      text: '会计审核中',
                    },
                    account_refuse: {
                      text: '会计拒绝',
                    },
                    completed: {
                      text: '已完成',
                    },
                  },
                  render: (dom, row) => (
                    <div
                      style={{
                        color: row?.status?.indexOf('refuse') != -1 ? 'red' : 'auto',
                        cursor: 'pointer',
                      }}
                      onClick={() => {
                        if (row.status == 'cashier_refuse') {
                          Modal.info({
                            title: '拒绝原因',
                            content: row.cashier_refuse_message,
                            maskClosable: true,
                          });
                        }
                      }}
                    >
                      {dom}
                    </div>
                  ),
                },
              ]}
              path="/wbn-api/payment_order"
              extraparams={{ company_id: iftype.curitem.id }}
              withCard={false}
              //cardtitle = "name" //卡片标题
              //cardavatar = "img_url" //卡片头像
            />
          </div>
        ) : iftype.curitem ? (
          <ProDescriptions
            title={`${iftype.curitem.name}的详细信息`}
            columns={
              iftype.val == 'see'
                ? [...columns.filter((it) => it.hideInDescription !== true)]
                : [...columnes.filter((it) => it.hideInDescription !== true)]
            }
            column={{ xs: 1, sm: 1, md: 2, lg: 3, xl: 4, xxl: 5 }}
            dataSource={iftype.curitem}
          />
        ) : (
          <InitForm
            fields={fields}
            submitData={(values) => {
              saveData(values);
            }}
            onChange={(changedValues, allValues) => {
              //联动操作
            }}
            submitting={props.loading.effects['business/addcompany'] || !vs}
          />
        )}
      </Modal>
    </div>
  );
}

export default connect(({ business, loading, user }) => ({
  business,
  loading,
  user,
}))(Company);
